package com.cmcc.sdtp.util;

import com.cmcc.sdtp.sdtp.util.DateUtil;
import com.cmcc.sdtp.sdtp.util.Util;
import com.cmcc.xdr.entity.AuthenEntity;
import com.cmcc.xdr.entity.BiccEntity;
import com.cmcc.xdr.entity.ComposedEntity;
import com.cmcc.xdr.entity.PccEntity;
import com.cmcc.xdr.entity.SipCallEntity;
import com.cmcc.xdr.entity.SipRegEntity;
import com.cmcc.xdr.entity.SipSrvccEntity;
import com.cmcc.xdr.entity.SrvccEntity;
/**
 * SaveSdtpInfo类的sql拼接工具类
 * @author dell
 *
 */
public class SdtpSaveSqlUtil240 {
	public static String sql(SipCallEntity  sipCall) {
		String sql = "('" + sipCall.getLength() + "','" + sipCall.getLocalProvince() + "','" + sipCall.getLocalCity()
				 + "','" + sipCall.getOwnerProvince() + "','" + sipCall.getOwnerCity() + "','" + sipCall.getRoamingType()
				 + "','" + sipCall.getInterFace() + "','" + sipCall.getXdrId() + "','" + sipCall.getRat() + "','"
				+ sipCall.getImsi() + "','" + sipCall.getImei() + "','" + sipCall.getMsisdn() + "','" + sipCall.getProcedureType() + "','"
				+ DateUtil.format(sipCall.getProcedureStartTime()) + "','" + DateUtil.format(sipCall.getProcedureEndTime()) + "','" + sipCall.getServiceType() + "','"
				+ sipCall.getProcedureStatus() + "','" + sipCall.getCallingNumber() + "','" + sipCall.getCalledNumber() + "','" 
				+ Util.sqlZhuanyi(sipCall.getCallingPartyUri()) + "','"
				+ Util.sqlZhuanyi(sipCall.getRequestUri()) 
				+ "','" + sipCall.getUserIp() + "','" 
				+ Util.sqlZhuanyi(sipCall.getCallId()) + "','" 
				+ Util.sqlZhuanyi(sipCall.getIcId()) + "','" 
				+ sipCall.getSourceNeIp() + "','"
				+ sipCall.getSourceNePort() + "','" + sipCall.getDestNeIp() + "','" + sipCall.getDestNePort() + "','" + sipCall.getCallSide() + "','"
				+ sipCall.getSourceAccessType() + "','" + sipCall.getSourceEci() + "','" + sipCall.getSourceTac() + "','" + sipCall.getSourceImsi() + "','"
				+ sipCall.getSourceImei() + "','" + sipCall.getSourceSbcDomain() + "','" + sipCall.getDestAccessType() + "','" + sipCall.getDestEci() + "','" + sipCall.getDestTac() + "','" + sipCall.getDestImsi()
				+ "','" + sipCall.getDestImei() + "','" + sipCall.getDestSbcDomain() + "','" + sipCall.getCallingSdpIpAddr() + "','" + sipCall.getCallingAudioSdpPort() + "','" + sipCall.getCallingVideoSdpPort()
				+ "','" + sipCall.getCalledSdpIpAddr() + "','" + sipCall.getCalledAudioSdpPort() + "','" + sipCall.getCalledVideoPort() + "','" + sipCall.getAudioCodec() + "','"
				+ sipCall.getVideoCodec() + "','" 
				+ Util.sqlZhuanyi(sipCall.getRedirectingPartyAddress()) + "','" 
				+ Util.sqlZhuanyi(sipCall.getOriginalPartyAddress()) + "','" + sipCall.getPrivacy() + "','" + sipCall.getRedirectReason() + "','"
				+ sipCall.getResponseCode() + "','" + sipCall.getFinishWarningCode() + "','" + sipCall.getFinishReasonProtocol() + "','" + sipCall.getFinishReasonCause() + "','" 
				+ sipCall.getCancelReasonProtocal() + "','" + sipCall.getCancelReasonCause() + "','" + sipCall.getReasonProtocolof183() + "','" + sipCall.getReasonCauseof183() + "','" + sipCall.getCallFailEnd() + "','"
				+ sipCall.getFirfailtime() + "','" + sipCall.getFirstFailNeIp() + "','" + sipCall.getFirstFailTransaction() + "','" 
				+ sipCall.getProgressTime() + "','" + sipCall.getPrackTime() + "','"+ sipCall.getUpdateTime1() + "','" + sipCall.getUpdateTime2() + "','" + sipCall.getUpdateTime3() + "','"
				+ sipCall.getAlertingTime() + "','" + sipCall.getAnswerTime() + "','" + sipCall.getReleaseTime() + "','" + sipCall.getCallDuration() + "','" 
				+ sipCall.getRetryAfter() + "','" + sipCall.getReleasePart() + "','" + sipCall.getUserAgent()+"','"/* + sipCall.getAtuSti() + "','" + sipCall.getcMsisdn() + "','" + sipCall.getSsi() + "','"*/
				+ sipCall.getInsertDate() + "')";
		sql = sql.replaceAll("\0", "");
		return sql;
	}
	
	public static String sql(SipSrvccEntity  sipSrvcc) {
		String sql =    "('" + sipSrvcc.getLength()  + "','" + sipSrvcc.getLocalProvince()  + "','" + sipSrvcc.getLocalCity()  + "','" 
				   + sipSrvcc.getOwnerProvince()  + "','" + sipSrvcc.getOwnerCity()  + "','" + sipSrvcc.getRoamingType()  + "','" 
				   + sipSrvcc.getInterFace()  + "','" + sipSrvcc.getXdrId()  + "','" + sipSrvcc.getRat()  + "','" + sipSrvcc.getImsi()  + "','" 
				   + sipSrvcc.getImei()  + "','" + sipSrvcc.getMsisdn()  + "','" + sipSrvcc.getProcedureType()  + "','" 
				   + DateUtil.format(sipSrvcc.getProcedureStartTime())  + "','" + DateUtil.format(sipSrvcc.getProcedureEndTime())  + "','" 
				   + sipSrvcc.getProcedureStatus() + "','" + sipSrvcc.getCallingNumber() + "','" 
				   + Util.sqlZhuanyi(sipSrvcc.getCallingPartyUri()) + "','" 
				   + Util.sqlZhuanyi(sipSrvcc.getRequestUri()) + "','" 
				   + sipSrvcc.getUserIp() + "','" 
				   + Util.sqlZhuanyi(sipSrvcc.getCallId()) + "','" 
				   + Util.sqlZhuanyi(sipSrvcc.getIcId()) + "','" 
				   + sipSrvcc.getSourceNeIp() + "','" + sipSrvcc.getSourceNePort() + "','" + sipSrvcc.getDestNeIp() + "','" 
				   + sipSrvcc.getDestNePort() + "','" + sipSrvcc.getSourceAccessType() + "','" + sipSrvcc.getSourceEci() + "','" 
				   + sipSrvcc.getSourceTac() + "','" + sipSrvcc.getSourceImsi() + "','" + sipSrvcc.getSourceImei() + "','" 
				   + sipSrvcc.getDestAccessType() + "','" + sipSrvcc.getDestEci() + "','" + sipSrvcc.getDestTac() + "','" 
				   + sipSrvcc.getDestImsi() + "','" + sipSrvcc.getDestImei() + "','" + sipSrvcc.getCallingSdpIpAddr() + "','" 
				   + sipSrvcc.getCallingAudioSdpPort() + "','" + sipSrvcc.getCallingVideoSdpPort() + "','" + sipSrvcc.getCalledSdpIpAddr() + "','" 
				   + sipSrvcc.getCalledAudioSdpPort() + "','" + sipSrvcc.getCalledVideoPort() + "','" + sipSrvcc.getAudioCodec() + "','" 
				   + sipSrvcc.getVideoCodec() + "','" + sipSrvcc.getResponseCode() + "','" + sipSrvcc.getFinishWarningCode() + "','" 
				   + sipSrvcc.getFinishReasonProtocol() + "','" + sipSrvcc.getFinishReasonCause() + "','"
				   + sipSrvcc.getCancelReasonProtocal() + "','" + sipSrvcc.getCancelReasonCause() + "','" + sipSrvcc.getReasonProtocolof183() + "','"
				   + sipSrvcc.getReasonCauseof183() + "','" + sipSrvcc.getCallFailEnd() + "','" + sipSrvcc.getFirfailtime() + "','" 
				   + sipSrvcc.getFirstFailNeIp() + "','" + sipSrvcc.getFirstFailTransaction() + "','" 
				   + sipSrvcc.getUpdateTime1() + "','" + sipSrvcc.getUpdateTime2() + "','" + sipSrvcc.getUpdateTime3() + "','" + sipSrvcc.getAlertingTime() + "','" 
				   + sipSrvcc.getAnswerTime() + "','" + sipSrvcc.getReleaseTime() + "','" + sipSrvcc.getCallDuration() + "','" 
				   + sipSrvcc.getAtuSti() + "','" + sipSrvcc.getCMsisdn() + "','" + sipSrvcc.getInsertDate() + "')";
		sql = sql.replaceAll("\0", "");
		return sql;
	}

	public static String sql(SipRegEntity  sipReg) {
		String sql = "('" + sipReg.getLength() + "','" + sipReg.getLocalProvince() + "','" + sipReg.getLocalCity()
				 + "','" + sipReg.getOwnerProvince() + "','" + sipReg.getOwnerCity() + "','" + sipReg.getRoamingType() + "','" + sipReg.getInterFace() + "','" + sipReg.getXdrId() + "','" + sipReg.getRat() + "','"
				+ sipReg.getImsi() + "','" + sipReg.getImei() + "','" + sipReg.getMsisdn() + "','" + sipReg.getProcedureType() + "','"
				+ DateUtil.format(sipReg.getProcedureStartTime()) + "','" + DateUtil.format(sipReg.getProcedureEndTime()) + "','" + sipReg.getProcedureStatus() + "','" 
				+ Util.sqlZhuanyi(sipReg.getRequestUri()) + "','"
				+ sipReg.getUserIp() + "','" 
				+ Util.sqlZhuanyi(sipReg.getCallid()) + "','" 
				+ Util.sqlZhuanyi(sipReg.getIcid()) + "','" 
				+ sipReg.getSourceNeIp() + "','" + sipReg.getSourceNePort() + "','"
				+ sipReg.getDestNeIp() + "','" + sipReg.getDestNePort() + "','" + sipReg.getSourceAccessType() + "','" + sipReg.getSourceEci() + "','" + sipReg.getSourceTac()
				+ "','" + sipReg.getAuthType() + "','" + sipReg.getExpiresTimeReq() + "','" + sipReg.getExpiresTimeRsp() + "','" + sipReg.getResponseCode() + "','"
				+ sipReg.getFinishWarningCode() + "','" + sipReg.getFinishReasonProtocol() + "','" + sipReg.getFinishReasonCause() + "','" 
				+ sipReg.getCancelReasonProtocal() + "','" + sipReg.getCancelReasonCause() + "','" + sipReg.getReasonProtocolof183() + "','" + sipReg.getReasonCauseof183() + "','"
				+ sipReg.getAuthReqTime() + "','" + sipReg.getAuthRspTime() + "','" + sipReg.getStnSr() + "','" + sipReg.getAtcfMgmt() + "','" + sipReg.getRetryAfter() + "','"
				+sipReg.getUserAgent() + "','"+ sipReg.getInsertDate() + "')";
		sql = sql.replaceAll("\0", "");
		return sql;
	}

	public static String sql(SrvccEntity srvcc) {
		String sql = "('" + srvcc.getLength() + "','" + srvcc.getLocalProvince() + "','" + srvcc.getLocalCity()
				 + "','" + srvcc.getOwnerProvince() + "','" + srvcc.getOwnerCity() + "','" + srvcc.getRoamingType() + "','" + srvcc.getInterFace() + "','" + srvcc.getXdrId() + "','" + srvcc.getRat() + "','"
				+ srvcc.getImsi() + "','" + srvcc.getImei() + "','" + srvcc.getMsisdn() + "','" + srvcc.getProcedureType() + "','" + DateUtil.format(srvcc.getProcedureStartTime())
				+ "','" + DateUtil.format(srvcc.getProcedureEndTime()) + "','" + srvcc.getSourceNeIp() + "','" + srvcc.getSourceNePort() + "','" + srvcc.getDestNeIp() + "','"
				+ srvcc.getDestNePort() + "','" + srvcc.getRoamDirection() + "','" + srvcc.getHomeMcc() + "','" + srvcc.getHomeMnc() + "','" + srvcc.getMcc() + "','"
				+ srvcc.getMnc() + "','" + srvcc.getTargetLac() + "','" + srvcc.getSourceTac() + "','" + srvcc.getSourceEci() + "','" + srvcc.getSvFlags() + "','"
				+ srvcc.getUlCMscIp() + "','" + srvcc.getDlCMmeIp() + "','" + srvcc.getUlCMscTeid() + "','" + srvcc.getDlCMmeTeid() + "','" + srvcc.getStnSr() + "','"
				+ srvcc.getTargetRncId() + "','" + srvcc.getTargetCellId() + "','" + srvcc.getArp() + "','" + srvcc.getRequestResult() + "','" + srvcc.getResult() + "','"
				+ srvcc.getSvCause() + "','" + srvcc.getPostFailureCause() + "','" + srvcc.getRespDelay() + "','" + srvcc.getSvDelay() + "','" + srvcc.getInsertDate() + "')";
		sql = sql.replaceAll("\0", "");
		return sql;
	}

	public static String sql(PccEntity  pcc) {
		String sql = "('" + pcc.getLength() + "','" + pcc.getLocalProvince() + "','" + pcc.getLocalCity()
				 + "','" + pcc.getOwnerProvince() + "','" + pcc.getOwnerCity() + "','" + pcc.getRoamingType() + "','" + pcc.getInterFace() + "','" + pcc.getXdrId() + "','" + pcc.getRat() + "','" + pcc.getImsi() + "','"
				+ pcc.getImei() + "','" + pcc.getMsisdn() + "','" + pcc.getProcedureType() + "','" + DateUtil.format(pcc.getProcedureStartTime()) + "','"
				+ DateUtil.format(pcc.getProcedureEndTime()) + "','" 
				+ Util.sqlZhuanyi(pcc.getIcid()) + "','"
				+ pcc.getTransactionStatus() + "','" + pcc.getSourceNeIp() + "','" + pcc.getSourceNePort() + "','" + pcc.getDestinationNeIp() + "','" + pcc.getDestinationNePort() + "','"
				+ Util.sqlZhuanyi(pcc.getOriginRealm()) + "','" 
				+ Util.sqlZhuanyi(pcc.getDestinationRealm()) + "','" 
				+ Util.sqlZhuanyi(pcc.getOriginHost()) + "','" 
				+ Util.sqlZhuanyi(pcc.getDestinationHost()) + "','" + pcc.getSgsnSgwSigIP() + "','" 
				+ Util.sqlZhuanyi(pcc.getAfAppID()) + "','" + pcc.getCcRequestType() + "','" + pcc.getRxRequestType()
				+ "','" + pcc.getMediaType() + "','" + pcc.getAbortCause() + "','" + pcc.getResultCode() + "','" + pcc.getExperimentalResultCode() + "','"
				+ pcc.getSessionReleaseCause() + "','" + pcc.getRuleFailureCode()
				+ "','" + pcc.getSessionId() + "','" + pcc.getIpv6Prefix() + "','" + pcc.getCalledStationId() + "','" 
				+ pcc.getRatType() + "','" + pcc.getServiceInfoStatus() + "','" + pcc.getUserEci() + "','" + pcc.getUserTac() + "','" + pcc.getQci() + "','"
				+ pcc.getInsertDate() + "')";
		sql = sql.replaceAll("\0", "");
		return sql;
	}
	
	public static String sql(BiccEntity nc) {
		String sql = "('" + nc.getLength()  + "','" + nc.getLocalProvince()  + "','" + nc.getLocalCity()  + "','" + 
			nc.getOwnerProvince()  + "','" + nc.getOwnerCity()  + "','" + nc.getRoamingType()  + "','" + 
			nc.getInterFace()  + "','" + nc.getXdrId()  + "','" + nc.getRat()  + "','" + nc.getImsi()  + "','" + 
			nc.getImei()  + "','" + nc.getMsisdn()  + "','" + 
			DateUtil.format(nc.getbTime())  + "','" + DateUtil.format(nc.geteTime())  + "','" + 
			nc.getProtocolId()  + "','" + nc.getSpckind()  + "','" + nc.getOpc()  + "','" + 
			nc.getDpc()  + "','" + nc.getPcm()  + "','" + nc.getCic()  + "','" + 
			nc.getSls()  + "','" + 
			Util.sqlsub(nc.getCallingNum(),26)  + "','" + 
			Util.sqlsub(nc.getCalledNum(),26)   + "','" + 
			Util.sqlsub(nc.getoCalledNum(),26)   + "','" + 
			Util.sqlsub(nc.getRecalledNum(),26)   + "','" + 
			Util.sqlsub(nc.getMsrn(),26)   + "','" + 
			nc.getCallingNumNature()  + "','" + nc.getCalledNumNature()  + "','" + 
			nc.getOcalledNumNature()  + "','" + nc.getRecalledNumNature()  + "','" + nc.getCalledStatus()  + "','" + 
			nc.getCallTrans()  + "','" + nc.getCallTransType()  + "','" + nc.getChargeind()  + "','" + 
			nc.getEventId()  + "','" + nc.getEventCause()  + "','" + nc.getEventResult()  + "','" + 
			nc.getSeizureDur()  + "','" + nc.getAnswerDur()  + "','" + nc.getAcmOffset()  + "','" + 
			nc.getAnmOffset()  + "','" + nc.getRelOffset()  + "','" + nc.getRlcOffset()  + "','" + 
			nc.getSaoOffset()  + "','" + nc.getAnsOffset()  + "','" + nc.getProcess1()  + "','" + 
			nc.getProcess2()  + "','" + nc.getProcess3()  + "','" + nc.getDirection1()  + "','" + 
			nc.getDirection2()  + "','" + nc.getDirection3()  + "','" + nc.getXdrType()  + "','" + 
			nc.getBearType()  + "','" + nc.getoAddresss()  + "','" + nc.getdAddresss()  + "','" + 
			nc.getCdrId()  + "','" + nc.getSessionId()  + "','" + nc.getGlobalId()  + "','" + nc.getInsertDate() + "')";
		sql = sql.replaceAll("\0", "");
		return sql;
	}

	public static String sql(AuthenEntity  Authen) {
		String sql = "('" + Authen.getLength()  + "','" + Authen.getLocalProvince() + "','" + Authen.getLocalCity()
				 + "','" + Authen.getOwnerProvince() + "','" + Authen.getOwnerCity() + "','" + Authen.getRoamingType() + "','" + Authen.getInterFace() + "','" + Authen.getXdrId() + "','" + Authen.getRat() + "','"
				+ Authen.getImsi() + "','" + Authen.getImei() + "','" + Authen.getMsisdn() + "','" + DateUtil.format(Authen.getProcedureStartTime()) + "','"
				+ DateUtil.format(Authen.getProcedureEndTime()) + "','" + Authen.getTransactionType() + "','" + Authen.getTransactionStatus() + "','" + Authen.getSourceNeIp()
				+ "','" + Authen.getSourceNePort() + "','" + Authen.getDestinationNeIp() + "','" + Authen.getDestinationNePort() + "','" + Authen.getResultCode() + "','"
				+ Authen.getExperimentalResultCode() + "','" 
				+ Util.sqlZhuanyi(Authen.getOriginRealm()) + "','" 
				+ Util.sqlZhuanyi(Authen.getDestinationRealm()) + "','" 
				+ Util.sqlZhuanyi(Authen.getOriginHost()) + "','"
				+ Util.sqlZhuanyi(Authen.getDestinationHost()) + "','"
				+ Authen.getDataReference() + "','" + Authen.getTadsResult() + "','" + Authen.getSessionId() + "','" + Authen.getUserEci() + "','" + Authen.getUserTac() + "','"
				+ Authen.getInsertDate() + "')";
		sql = sql.replaceAll("\0", "");
		return sql;
	}

	public static String sql(ComposedEntity composed) {
		String sql = "('" + composed.getLength() + "','" + composed.getLocalProvince() + "','" + composed.getLocalCity() + "','"
				+ composed.getOwnerProvince() + "','" + composed.getOwnerCity() + "','" + composed.getRoamingType() + "','" + composed.getRat() + "','" + composed.getXdrType() + "','" + composed.getXdrId() + "','"
				+ composed.getImsi() + "','" + composed.getImeisv() + "','" + composed.getMsisdn() + "','" + composed.getProcedureType() + "','" + DateUtil.format(composed.getProcedureStartTime()) + "','" + DateUtil.format(composed.getProcedureEndTime()) + "','"
				+ composed.getProcedureStatus() + "','" + composed.getCallingNumber() + "','" + composed.getCalledNumber() + "','" + composed.getServiceScenario() + "','" + composed.getXdrnumber() + "','" + composed.getServiceType() + "','"
				+ composed.getResponseCode() + "','" + composed.getReasonCause() + "','" + composed.getFinishReasonCause() + "','" + composed.getFirstFailTime() + "','" + composed.getFirstFailNeIp() + "','" + composed.getInterface() + "','"
				+ composed.getSingleXdrId() + "','" + composed.getSingleProcedureType() + "','" + DateUtil.format(composed.getSingleStartTime()) + "','" + DateUtil.format(composed.getSingleEndTime()) + "','" + composed.getSingleProcedureStat() + "','" + composed.getSourceNeIP() + "','"
				+ composed.getSourceNePort() + "','" + composed.getDestinationNeIP() + "','" + composed.getDestinationNePort() + "','" +composed.getCallSide() + "','" +composed.getAlertingTime() + "','" 
				+ composed.getAnswerTime() + "','" + composed.getSvResult() + "','" + composed.getSvRespDelay() + "','" +composed.getSvDelay() + "','"
				+ composed.getInsertDate() + "')";
		sql = sql.replaceAll("\0", "");
		return sql;
	}
}
